Skip to content

Conversation

@SPFabGerman
Copy link
Contributor

When a clienticon widget is created without specifying a client (for example when the widget is created declaratively), then the client attribute is set to nil. But the property::icon signal is called anyways, leading to an error because a nil value is referenced in the first condition of the if-clause.
I fixed this by swapping both conditions. Since the signal is only called for existing clients, c is never nil and so the check obj._private.client == c doubles to ensure that obj._private.client exists and that obj._private.client.valid can be referenced.

@Aire-One
Copy link
Member

What's your use case @SPFabGerman ?

The widget is meant to be instantiated, even in declarative structure. Just like awful.titlebar.widget. See examples https://awesomewm.org/apidoc/popups_and_bars/awful.titlebar.html

It doesn't make sense to me to use the clienticon widget without specifying the client it should source the icon from.

Maybe an evolution could be to allow declarative usage with the named parameters pattern. But that's really just a stylistic improvement.

@SPFabGerman
Copy link
Contributor Author

My use case is as a template for both a tasklist and a taglist:
(The taglist code is pretty similar.)

    local function update_tasklist_callback(self, c, index, objects)
        self:get_children_by_id("client_icon_role")[1].client = c
    end

    local tasklist = awful.widget.tasklist {
        screen  = s,
		...
        widget_template = {
            id     = "background_role",
            widget = wibox.container.background,
            create_callback = update_tasklist_callback,
            update_callback = update_tasklist_callback,
            {
                widget = wibox.container.place,
                {
                    layout = wibox.layout.fixed.horizontal,
                    {
                        widget  = wibox.container.margin,
                        margins = 2,
                        {
                            id     = "client_icon_role",
                            widget = awful.widget.clienticon,
                        },
                    },
                    {
                        id     = "text_role",
                        widget = wibox.widget.textbox,
                    }
                }
            }
        }
    }

Because I use it in a template I can only specify the client with the two callbacks. But these seem to only be called after the widget has already been created. I know that I can use an imagebox widget with the icon_role id to solve this, but that doesn't have as high of a resolution.

The code has been adapted from https://awesomewm.org/apidoc/widgets/awful.widget.tasklist.html where pretty much the same thing is done.

Copy link
Member

@actionless actionless left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i didn't had time to dig into the usecase, but i don't see any technical problem with this change

@codecov
Copy link

codecov bot commented Dec 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.42%. Comparing base (9475bb9) to head (4ac7bb6).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4044   +/-   ##
=======================================
  Coverage   90.41%   90.42%           
=======================================
  Files         938      938           
  Lines       60232    60232           
  Branches     1139     1139           
=======================================
+ Hits        54457    54463    +6     
+ Misses       5269     5263    -6     
  Partials      506      506           
Files with missing lines Coverage Δ
lib/awful/widget/clienticon.lua 84.05% <100.00%> (ø)

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Aire-One
Copy link
Member

The default_template from awful.widget.tasklist does use the awful.widget.clienticon widget. So there is definitely something to dig.

@mergify mergify bot merged commit 84ab66d into awesomeWM:master Jan 3, 2026
10 checks passed
@Aire-One
Copy link
Member

Aire-One commented Jan 3, 2026

Oops, forget to approve with my comment.

JimmyCozza added a commit to trip-zip/somewm that referenced this pull request Jan 14, 2026
Swap condition order to check `obj._private.client == c` before
accessing `.valid`, preventing crash when clienticon widget is
created without a client (e.g., in declarative templates).

Upstream: awesomeWM/awesome#4044
JimmyCozza added a commit to trip-zip/somewm that referenced this pull request Jan 14, 2026
Swap condition order to check `obj._private.client == c` before
accessing `.valid`, preventing crash when clienticon widget is
created without a client (e.g., in declarative templates).

Upstream: awesomeWM/awesome#4044
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants